package 动态规划9月;
// https://leetcode-cn.com/problems/n-th-tribonacci-number/
public class DP1137第N个泰波那契数0918 {
    class Solution {
        public int tribonacci(int n) {
            if(n==0)return 0;
            if(n<=2)return 1;
            int a=0,b=1,c=1,d=0;
            for(int i=3;i<=n;i++)
            {
                d=a+b+c;
                a=b;
                b=c;
                c=d;
            }
            // return tribonacci(n-2)+tribonacci(n-1)+tribonacci(n-3);
            return d;
        }
    }
}
